<template>
  <el-table
    :data="tableList"
    style="width: 100%"
  >
    <el-table-column prop="orderId" label="项目编号"/>
    <el-table-column prop="userNameSt" label="下单人"/>
    <el-table-column prop="date" label="下单人电话"/>
    <el-table-column prop="price" label="项目金额" />
    <el-table-column prop="content" label="评价"/>
    <el-table-column
      prop="attements"
      label="评价图片"
    >
      <template slot-scope="scope">
        <el-image style="width: 100px; height: 100px" fit="fit" :src="getAttementsPic(scope.row.attements)"></el-image>
      </template>
    </el-table-column>
    <el-table-column
      label="操作"
      fixed="right"
      width="230"
    >
      <template slot-scope="scope">
        <el-button type="primary" size="small" @click="onDeleteComment(scope.row)">删除评价</el-button>
        <el-button type="primary" size="small" @click="onEditComment(scope.row)">查看</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import { delYzComment } from '@/api/yzComment';

export default ({
  name: 'MasterCommentTable',
  props: {
    tableList: {}
  },
  data() {
    return {

    }
  },
  methods: {
    async getCommentList() {
      // const 
    },
    async onDeleteComment(records) {
      const { data } = await delYzComment(records.id);
      if (data.code === 200) {
        this.$message({
          message: '删除成功',
          type: 'success',
        });
        this.$emit('refreshList');
      } else {
        this.$message({
          message: data.msg || '删除失败',
          type: 'error',
          showClose: true,
          duration: 3000,
        });
      }
    },
    onEditComment(records) {
      this.$router.push({ name: "master_comment_detail", params: { id: records.id, isEdit: true, records }});
    },
    getAttementsPic(str) {
      const currPic = str && str.split(',');
      if (currPic && currPic.length && typeof currPic === 'object') {
        return currPic[0]
      }
      return '';
    }
  }
})

</script>
